<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增任务')" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-mission-add">
        <div class="form-group">
            <label class="col-sm-3 control-label">延期任务名称：</label>
            <div class="col-sm-8">
                <select name="missionId" class="form-control" id="missionId">
                    <option>请选择需要延期的任务</option>
                    <option th:each="mission : ${missionList}" th:value="${mission.missionId}" th:text="${mission.missionTitle}"></option>
                </select>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">执行人：</label>
            <div class="col-sm-8">
                <select name="infoId" class="form-control" id="infoId">
                </select>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">延期理由：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="postponeText" id="postponeText" required>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">延期到：</label>
            <div class="col-sm-8">
                <input class="form-control" type="date" name="postponeTime" id="postponeTime" required>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">备注：</label>
            <div class="col-sm-8">
                <textarea id="remark" name="remark" class="form-control"></textarea>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer" />
<script type="text/javascript">


    $(function () {
        $("#missionId").change(function () {
            var missionId = $("#missionId").val();
            $.post(
                '/task/mission/selectOneTaskMission',
                {
                    missionId:missionId
                },
                function(data){
                    console.log(data);
                    if(data != null){
                        $("#infoId").empty();
                        $("#infoId").append("<option value='" + data.infoId + "'>" + data.infoName + "</option>");
                    }
                },"json"
            )
        })
    })

    var prefix = ctx + "task/postpone";

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/add", $('#form-mission-add').serialize());
        }
    }
</script>
</body>
</html>
